package cn.springcloud.alibaba.admin.controller.v1;

import cn.springcloud.alibaba.core.base.Result;
import cn.springcloud.alibaba.core.base.ResultCode;
import cn.springcloud.alibaba.sys.dto.SysMenuDTO;
import cn.springcloud.alibaba.sys.feign.SysMenuFeignClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/v1/api/menu")
public class MenuController {

	@Autowired
	private SysMenuFeignClient sysMenuFeignClient;

	@GetMapping
	public Result<List<SysMenuDTO>> getSysMenus() {
		try {
			Result<List<SysMenuDTO>> result = sysMenuFeignClient.getSysMenus();
			return result;
		} catch (Exception e) {
			return Result.error(ResultCode.RESULT_DATA_NOTFOUND);
		}
	}
}
